function Q=fit_psi(psi,pi,delta,mu)

gamma=psi(1);
kappa=psi(2);

sigma=exp(kappa);
pi_hat=signalcdf(gamma,mu,sigma);
b=1/(1+((1-mu)/mu)*exp((0.5-gamma)/sigma^2));

type1=normcdf(-0.5/sigma-sigma*log(((1-b)*mu)/(b*(1-mu))));
delta_hat=type1*mu/pi_hat; 

Q=[pi-pi_hat;delta-delta_hat];